package cn.beyond.vehicleManagement.controller;


import com.google.gson.JsonObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(urlPatterns = {"/controller"})
public class ControllerServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /**
         *  控制index页面跳转
         */
      String controller =  req.getParameter("controller");

      // 从数据库字典表里面去取

        // 这是一个注释
        if ("1".equals(controller)) {
            controller = "pages/employee/employeemanage.jsp";
        }else {
            controller = "pages/driver/driving_license.jsp";
        }
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("status", "return");
        jsonObject.addProperty("url",controller);
      PrintWriter out = resp.getWriter();
      // 这里也搞个json对象，加个属性url用来记录从数据库中获取到的页面路径
      out.print(jsonObject);
    }
}
